package com.swkl.yuan.agvtask.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.swkl.yuan.agvtask.entity.AgvConfig;
import com.swkl.yuan.agvtask.entity.AgvTask;
import com.swkl.yuan.agvtask.entity.SystemConfig;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * Project: AGVTask  package:  com.swkl.yuan.agvtask.controller  -  IndexController
 * Powered by zhiyuan On 2024-06-19 18:09:31
 *
 * @author alkin
 * @version 1.0
 */
@Controller
public class IndexController {





    @GetMapping ("/logsIndex")
    public  String logIndex(){
        return "log";
    }
    @GetMapping ("/")
    public  String list(){
        return "agvTask";
    }

    @GetMapping ("/sysConfig")
    public  String sysConfig(Model model ){
        SystemConfig systemConfig = new SystemConfig().selectById(900001);
        AgvConfig agvConfig = new AgvConfig().selectById(900001);
        model.addAttribute("ip",systemConfig.getIp());
        model.addAttribute("dbAddress",systemConfig.getDbAddress());
        model.addAttribute("plcType",systemConfig.getPlcType());
        model.addAttribute("heartbeatOffset",systemConfig.getHeartbeatOffset());
        model.addAttribute("errorOffset",systemConfig.getErrorOffset());
        model.addAttribute("requestMoveApi",agvConfig.getRequestMoveApi());
        model.addAttribute("requestFinishApi",agvConfig.getRequestFinishApi());
        return "sysConfig";
    }
    @GetMapping ("/addAgvTask")
    public  String addTask(){
        return "addAgvTask";
    }
    @GetMapping ("/batchReplace")
    public  String batchReplace(String pram,Model model){
        model.addAttribute("data",pram);
        return "batchReplace";
    }

    @GetMapping ("/modifyAgvTask/{id}")
    public  String modifyAgvTask(@PathVariable("id") Long id, Model model ){
        model.addAttribute("data",new AgvTask().selectById(id));
        return "modifyAgvTask";
    }
}
